<%@page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page contentType="text/html; charset=UTF-8"%>
<!DOCTYPE HTML>
<html manifest="appli.manifest">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<% if (request.getHeader("USER-AGENT").contains("iPhone") || request.getHeader("USER-AGENT").contains("iPod") || request.getHeader("USER-AGENT").contains("iPad")) { %>
<meta name='viewport' content='target-densitydpi=480,user-scalable=no,maximum-scale=1.0'/>
<% } else { %>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,target-densitydpi=high-dpi,user-scalable=no">
<% } %>
<meta content="telephone=no" name="format-detection">
<META HTTP-EQUIV="pragma" CONTENT="no-cache"> 
<META HTTP-EQUIV="expires" CONTENT="0"> 
<META HTTP-EQUIV="Cache-Control" CONTENT="no-store, must-revalidate"> 
<title>西游斗地主</title>
<link type="text/css" rel="stylesheet" href="css/common_new.css">
<link type="text/css" rel="stylesheet" href="css/tab.css">
<style>
#container{top:150px;left:50px;position:absolute}
.landlordLoad-text{width:504px;height:198px; position:absolute; top:10%; left:50%; margin-left:-252px;}
</style>
</head>


<body>
	
	<!--背景-->
	<div id="scene" class="scene" >
			<div class="loadBar">
				<span class="loadBaring"></span>
			</div>
			<div class="landlordLoad-text"><img  src="images/xy/logo2.png"  /></div>
		
	</div>


	<script src="js/zepto.min.js"></script>
	<script src="js/require.min.js"></script>
	<script src="js/quark.base-1.0.0.min.js"></script>
	
	<script>
		window.onload=function(){
			
			require(["js/mCommon.js","js/mEffect.js"], function(common,effect){  
				common.setSize();
				//effect.runCat();
			});
			
		};
		
		var forTime=(new Date()).getTime();
		setInterval(function(){
			forTime=(new Date()).getTime();
		},50);
		function getServiceURL(){
			var pathName = window.location.pathname;
			var projectName = pathName.substring(0,pathName.substr(1).indexOf('/')+1);
			return "http://"+window.location.host + projectName;
		}
	
		function forward(){
			console.log("----------->load.jsp forward!");
			var pathName = window.location.pathname;
			var projectName = pathName.substring(0,pathName.substr(1).indexOf('/')+1);
			location.href = "http://"+window.location.host + projectName + "/start.jsp?"+forTime;
		}
		
		function redirect(){
			console.log("----------->redirect status:"+window.applicationCache.status);
			if(window.applicationCache.status == 1){
				console.log("----------->redirect status:1");
				forward();
			}
			if(window.applicationCache.status == 2){
				setTimeout(function(){
					console.log("-----status=2,redirect>>>");
					forward();
				},1200);
			}
		}
		
		
		window.applicationCache.onchecking=function(e){
			console.log("--->checking for application updata");
			redirect();
		};
		
		window.applicationCache.onnoupdate=function(e){
			console.log("----------->onnoupdate");
			forward();
		};
		
		window.applicationCache.onprogress=function(e){
			
			var l = (e.loaded/e.total)*424;
			$(".loadBaring").width(l);
			$("#container").css({
				 "-webkit-transform":"translate("+l+"px,0px)"
			});
			//$(".landlordLoad-text").html("下载个数"+e.loaded+"/"+e.total);
			if(e.loaded === e.total){
				console.log("----------->onprogress");
				forward();
			}
		};
		
		/**
		setTimeout(function(){
			console.log("----------->setTimeout");
			 noSupport();
		},20000);
		
		*/
		
		window.applicationCache.onerror=function(){
			console.log("----------->window.applicationCache.onerror");
          	noSupport();
       	};
       	if(!window.applicationCache){
       		console.log("----------->window.applicationCache");
       		noSupport();
       	}
      
        
        function noSupport(){
        	 setTimeout(function(){
				 $(".loadBaring").animate({
    				"width":424
    			},3000);
				$("#container").css({
					 "-webkit-transform":"translate(424px,0px)",
					  "-webkit-transition":"-webkit-transform 3s linear"
				});
				
				 setTimeout(function(){
					console.log("----------->noSupport");
					forward();
				},3000)	;
			},500);
        }
		
		
		
	
	</script>
</body>
</html>